<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2015/8/26
  Time: 13:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://"
          + request.getServerName() + ":" + request.getServerPort()
          + path + "/";
  String jsessionid = session.getId();
%>

<div class="row">
  <!-- NEW WIDGET START -->
  <article class="col-sm-12 col-md-12 col-lg-12">
    <div class="jarviswidget well" id="wid-id-3"
         data-widget-colorbutton="false"
         data-widget-editbutton="false"
         data-widget-togglebutton="false"
         data-widget-deletebutton="false"
         data-widget-fullscreenbutton="false"
         data-widget-custombutton="false"
         data-widget-sortable="false">
      <!-- widget div-->

      <div class="widget-body">
        <a class="btn btn-default pull-right pull-right-fix" id="btn-save-stepcon" href="javascript:void(0);" style="position: relative;z-index:99"><i class="fa fa-lg fa-download"></i> 保存</a>
        <hr class="simple">
        <form id="stepcon" class="smart-form" novalidate="novalidate" action="" method="post">
          <input type="hidden" name="keyId" id="keyId" value="<s:property value="stepCon.id" />"/>
          <input type="hidden" name="parentId" id="parentId" value="<s:property value="stepCon.stepBrief.id" />"/>
          <header  style="display: block;">
            步骤条件表&nbsp;&nbsp;<span id="title"></span>
          </header>
          <fieldset>

            <div class="row">
              <label class="label col col-3">
                <i class="fa fa-asterisk txt-color-red"></i>
                条件名称
              </label>
              <section class="col col-8">
                <label class="input">
                  <input  type="text" name="stepName" id="stepName" placeholder="请输入条件名称" value="<s:property value="stepCon.name"/>" >
                </label>
              </section>
            </div>
            <div class="row">
              <label class="label col col-3">
                <i class="fa fa-asterisk txt-color-red"></i>
                条件描述
              </label>
              <section class="col col-8">
                <label class="input">
                  <input type="text" name="content" id="content" placeholder="请输入条件描述" value="<s:property value="stepCon.content"/>" >
                </label>
              </section>
            </div>
            <div class="row">
              <label class="label col col-3">
                <i class="fa fa-asterisk txt-color-red"></i>
                条件公式
              </label>
              <section class="col col-3">
                <label class="input">
                  <select class="form-control" name="formulaField" id="formulaField">
                    <option value="">--请选择--</option>
                    <s:iterator value="fieldNames" id="arr" status="st" >
                      <option  value="<s:property value="#arr"/>"  <s:if test='#arr==stepCon.formulaField'>selected</s:if>><s:property value="#arr"/></option>
                    </s:iterator>
                  </select>
                </label>
              </section>
              <section class="col col-2">
                <label class="input">
                  <select class="form-control" name="formulaFlag" id="formulaFlag">
                    <option value=""></option>
                    <option value=">" <s:if test='">"==stepCon.formulaFlag'>selected</s:if>>大于</option>
                    <option value=">=" <s:if test='">="==stepCon.formulaFlag'>selected</s:if>>大于等于</option>
                    <option value="==" <s:if test='"=="==stepCon.formulaFlag'>selected</s:if>>等于</option>
                    <option value="<" <s:if test='"<"==stepCon.formulaFlag'>selected</s:if>>小于</option>
                    <option value="<=" <s:if test='"<="==stepCon.formulaFlag'>selected</s:if>>小于等于</option>
                    <option value="!=" <s:if test='"!="==stepCon.formulaFlag'>selected</s:if>>不等于</option>
                  </select>
                </label>
              </section>
              <section class="col col-3">
                <label class="input">
                  <input type="text" name="formulaVal" id="formulaVal" placeholder="请输入条件值" value="<s:property value="stepCon.formulaVal"/>" >
                </label>
              </section>
            </div>
            <div class="row">
              <label class="label col col-3">
                <i class="fa fa-asterisk txt-color-red"></i>
                对应步骤编号
              </label>
              <section class="col col-8">
                <label class="input">
                  <input type="text" name="stepNo" id="stepNo" placeholder="请输入对应步骤编号" value="<s:property value="stepCon.stepNo"/>" >
                </label>
              </section>
            </div>
          </fieldset>
        </form>
      </div>
    </div>

  </article>
</div>

<script>


  $(function(){
    //保存
    $("#btn-save-stepcon").click(
            function(){
              var $validForm = $("#stepcon").valid();
              if(!$validForm) return false;
              $("#btn-confirm-common").attr("disabled", "disabled");
              form_save("stepcon","../com/ajax-stepcon!save.action");
              jQuery("#ajax_stepCon_table").trigger("reloadGrid");
              // var parentId = $('#stepcon #parentId').val();
              // loadURL("../com/ajax-stepbrief!input.action?keyId="+parentId,$('div#s2'));
              gDialog.fClose();
            }
    );

  });




  //校验
  $("#stepcon").validate({
    rules : {
      stepName : {
        required : true
      },
      formulaField : {
        required : true
      },
      formulaFlag : {
        required : true
      },
      formulaVal: {
        required : true
      },
      stepNo : {
        required : true
      }
    },
    messages : {
      stepName : {
        required : "请输入条件名称"
      },
      formulaField : {
        required : "请选择条件域名"
      },
      formulaFlag : {
        required : "请选择条件符号"
      },
      formulaVal: {
        required : "请输入条件值"
      },
      stepNo : {
        required : "请输入对应步骤编号"
      }
    },
    ignore: "",
    errorPlacement : function(error, element) {
      if(element.is(":radio")){
        element.parents("div.inline-group").append(error);
      }else {
        error.insertAfter(element.parent());
      }
    }
  });





</script>
